package com.itcast.plane.modoule.company.controller;

import com.itcast.plane.modoule.company.domain.Company;
import com.itcast.plane.modoule.company.dto.CompanyCreatDTO;
import com.itcast.plane.modoule.company.service.CompanyService;
import com.itcast.plane.util.JsonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/company")
public class CompanyController {

    @Resource
    private CompanyService companyService;

    @PostMapping("/add")
    public JsonResult addCompany(@RequestBody CompanyCreatDTO creatDTO){
        return companyService.addCompany(creatDTO);
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult deleteCompany(@PathVariable int id){
        return companyService.deleteCompany(id);
    }

    @PutMapping("/edit")
    public JsonResult editCompany(@RequestBody Company company){
        return companyService.editCompany(company);
    }

    @GetMapping("/getpage")
    public JsonResult getPage(@RequestParam int pages){
        return companyService.getPage(pages);
    }

    @GetMapping("/getall")
    public JsonResult getAll(){
        return companyService.getAll();
    }
}
